package leetcode_数与位._01数字的位操作;

/**
 * @author yzh
 * @data 2021/3/25 21:57
 * 汉明距离
 * 两个数字异或后 1 的数量
 */
public class _461_汉明距离 {

    public int hammingDistance(int x, int y) {
        x = x ^ y;
        int ans = 0;
        while (x != 0) {
            int tem = x & 1;
            if (tem == 1) ++ans;
            x = x >> 1;
        }
        return ans;
    }
}
